
 
 
 
 
 ************************Table A3*****************************************************************
  ************************Table A3*****************************************************************
   ************************Table A3*****************************************************************
 *--------------------------------------------------------
 * 1. Bootstrap Inverval Table 3 in the Appendix (exclude outliers)
 *----------------------------------------------------------
 
 
*(column 1 2 5 6 of Table 3 in the Appendix)
 clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************
sort firm year
mata DLW_TRANSLOG()
end 
use "D:\Nanjing\2019\pollution2\submission\data\boot1",clear
rename frdm firm
gen hangye=int(cic_adj/100)
drop if hangye<13
drop if hangye>42

*keep if hangye==27|hangye==14
capture drop cic2
capture drop cic4 
gen cic2=floor(cic_adj/100)
egen gcic4=group(cic_adj)
egen SDcic=sd(cic2), by(firm)
egen cic_y=group(cic year)
gen Productivity=tfp_acf_new
*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------

capture program drop prodboot
program define prodboot, rclass
preserve






* Re-estimate firm-level production function for each sample from bootstrap
do "D:\Nanjing\2019\pollution2\do file\for accre\do file\tfp_combine.do"

xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs





*************************************************************************************************
* For so2+ IV: column 1 of Table 3 in the Appendix
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   ///
tfp_acf_new lntariff  i.cic i.prov i.year i.ownership if lnso2<5.64339&lndust<5.265027, partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c1=_b[exp_dummy2]
return scalar abt_t2c1=_b[so2_new1]
return scalar tfp_t2c1=_b[tfp_acf_new]
return scalar tar_t2c1=_b[lntariff]


*column 2 of Table 3 in the Appendix
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   ///
tfp_acf_new lntariff lntariff lnkl_lag lnso2_ini i.cic i.prov i.year  i.ownership if lnso2<5.64339&lndust<5.265027, partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1]
return scalar tfp_t2c2=_b[tfp_acf_new]
return scalar tar_t2c2=_b[lntariff]
return scalar klr_t2c2=_b[lnkl_lag]
return scalar iei_t2c2=_b[lnso2_ini]




************************************************************************************************************************************
* For dust +IV: column 5 of Table 3 in the Appendix
ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation) ///
  tfp_acf_new lntariff  i.cic i.prov i.year  i.ownership if lnso2<5.64339&lndust<5.265027, partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c3=_b[exp_dummy2]
return scalar abt_t2c3=_b[dust_new1]
return scalar tfp_t2c3=_b[tfp_acf_new]
return scalar tar_t2c3=_b[lntariff]


*column 6 of Table 3 in the Appendix
ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation) ///
  tfp_acf_new lntariff lntariff lnkl_lag lndust_ini i.cic i.prov i.year  i.ownership if lnso2<5.64339&lndust<5.265027, partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1]
return scalar tfp_t2c4=_b[tfp_acf_new]
return scalar tar_t2c4=_b[lntariff]
return scalar klr_t2c4=_b[lnkl_lag]
return scalar iei_t2c4=_b[lndust_ini]


***************************************************************************************************************************************


end

capture drop indc
egen indc=group(firm)
drop if indc==.

* Columns (1) (2) (5) and (6) of Table 4

bootstrap  exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  ///
 exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) tfp_t2c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)   klr_t2c2=r(klr_t2c2) iei_t2c2=r(iei_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)   ///
 exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4) iei_t2c4=r(iei_t2c4) ,  ///
 reps(50)  seed(1) nodrop cluster(indc) idcluster(newid): prodboot
 

 
 ***********************************************************************************
 ***********************************************************************************
 
 
 
 
 
 
 
 
 
 
 *******************************************************************************
 *Part II: Columns 3, 4, 7, 8 of Table A3
 *****************************************************************************
 
  clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************
sort firm year
mata DLW_TRANSLOG()
end 



use "D:\Nanjing\2019\pollution2\submission\data\boot_app2",clear


*rename party_id frdm

*
*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------
keep if _merge==2|_merge==3
capture program drop prodboot
program define prodboot, rclass
preserve






* Re-estimate firm-level production function for each sample from bootstrap



xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs







*************************************************************************************************
* For so2+ IV: column 2 of Table 2

 ivreghdfe lnso2  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation) Productivity Tariff lnKL if lnso2<5.64339&lndust<5.265027, a(indc_firm year)

return scalar exp_t2c1=_b[Export]
return scalar abt_t2c1=_b[Abatement_so2]
return scalar tfp_t2c1=_b[Productivity]
return scalar tar_t2c1=_b[Tariff]
return scalar klr_t2c1=_b[lnKL]


ivreghdfe lnso2_d  (exp_dummy2 so2_new1_d= treatment_tfp treatment_so2  ventilation)  ///
 tfp_acf_new_d lntariff_d lnkl_d if lnso2<5.64339&lndust<5.265027, a(cic prov year ownership lndust_ini)

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1_d]
return scalar tfp_t2c2=_b[tfp_acf_new_d]
return scalar tar_t2c2=_b[lntariff_d]
return scalar klr_t2c2=_b[lnkl_d]



 ivreghdfe lndust  (Export Abatement_dust= tariff_prod ventilation_prod  ventilation) Productivity Tariff lnKL if lnso2<5.64339&lndust<5.265027, a(indc_firm year)

return scalar exp_t2c3=_b[Export]
return scalar abt_t2c3=_b[Abatement_dust]
return scalar tfp_t2c3=_b[Productivity]
return scalar tar_t2c3=_b[Tariff]
return scalar klr_t2c3=_b[lnKL]

ivreghdfe lndust_d  (exp_dummy2 dust_new1_d= treatment_tfp treatment_dust  ventilation)  ///
 tfp_acf_new_d lntariff_d lnkl_d if lnso2<5.64339&lndust<5.265027, a(cic prov year ownership lndust_ini) 
return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1_d]
return scalar tfp_t2c4=_b[tfp_acf_new_d]
return scalar tar_t2c4=_b[lntariff_d]
return scalar klr_t2c4=_b[lnkl_d]


end

capture drop indc2
egen indc2=group(firm year)
drop if indc2==.



bootstrap   exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  klr_t2c1=r(klr_t2c1) ///
exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) tfp_t3c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)  klr_t2c2=r(klr_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)  klr_t2c3=r(klr_t2c3) ///
exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4), ///
 rep(50)  seed(5) nodrop : prodboot

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 ***********************************Table A4*****************************************************
 ***********************************Table A4*****************************************************
 ***********************************Table A4*****************************************************
 ***********************************Table A4*****************************************************
 
 
 
 *--------------------------------------------------------
 * 2. Bootstrap Inverval Table A4 in the Appendix
 *----------------------------------------------------------
 
 
*(column 1 2 5 6 of Table A4 in the Appendix)
 clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************
sort firm year
mata DLW_TRANSLOG()
end 
use "D:\Nanjing\2019\pollution2\submission\data\boot1",clear
rename frdm firm
gen hangye=int(cic_adj/100)
drop if hangye<13
drop if hangye>42

*keep if hangye==27|hangye==14
capture drop cic2
capture drop cic4 
gen cic2=floor(cic_adj/100)
egen gcic4=group(cic_adj)
egen SDcic=sd(cic2), by(firm)
egen cic_y=group(cic year)
gen Productivity=tfp_acf_new
*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------

capture program drop prodboot
program define prodboot, rclass
preserve






* Re-estimate firm-level production function for each sample from bootstrap
do "D:\Nanjing\2019\pollution2\do file\for accre\do file\tfp_combine.do"

xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs





*************************************************************************************************
* For so2+ IV: column 1 of Table 4 in the Appendix
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   ///
tfp_acf_new lntariff  i.cic i.prov i.year if year!=2004, partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c1=_b[exp_dummy2]
return scalar abt_t2c1=_b[so2_new1]
return scalar tfp_t2c1=_b[tfp_acf_new]
return scalar tar_t2c1=_b[lntariff]


*column 2 of Table 4 in the Appendix
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   ///
tfp_acf_new lntariff lntariff lnkl_lag lnso2_ini i.cic i.prov i.year if year!=2004, partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1]
return scalar tfp_t2c2=_b[tfp_acf_new]
return scalar tar_t2c2=_b[lntariff]
return scalar klr_t2c2=_b[lnkl_lag]
return scalar iei_t2c2=_b[lnso2_ini]




************************************************************************************************************************************
* For dust +IV: column 5 of Table 4 in the Appendix
ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation) ///
  tfp_acf_new lntariff  i.cic i.prov i.year if year!=2004, partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c3=_b[exp_dummy2]
return scalar abt_t2c3=_b[dust_new1]
return scalar tfp_t2c3=_b[tfp_acf_new]
return scalar tar_t2c3=_b[lntariff]


*column 6 of Table 4 in the Appendix
ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation) ///
  tfp_acf_new lntariff lntariff lnkl_lag lndust_ini i.cic i.prov i.year if year!=2004, partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1]
return scalar tfp_t2c4=_b[tfp_acf_new]
return scalar tar_t2c4=_b[lntariff]
return scalar klr_t2c4=_b[lnkl_lag]
return scalar iei_t2c4=_b[lndust_ini]


***************************************************************************************************************************************


end

capture drop indc
egen indc=group(firm)
drop if indc==.
*------------------------------------------------------
* Columns (1) (2) (5) and (6) of Table A4
*-------------------------------------------------------
bootstrap  exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  ///
 exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) tfp_t2c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)   klr_t2c2=r(klr_t2c2) iei_t2c2=r(iei_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)   ///
 exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4) iei_t2c4=r(iei_t2c4) ,  ///
 reps(50)  seed(1) nodrop cluster(indc) idcluster(newid): prodboot
 

 
 **************************************************************
 
 
 
 
 
 
 
 
 ****************************************************************************
 * (2)column 3, 4 , 7, and 8 of Table A4 in the Appendix
 *--------------------------------------------------------

   mata:
void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************
sort firm year
mata DLW_TRANSLOG()
end 
use "D:\Nanjing\2019\pollution2\submission\data\boot_app2",clear



*
*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------
keep if _merge==2|_merge==3
capture program drop prodboot
program define prodboot, rclass
preserve






* Re-estimate firm-level production function for each sample from bootstrap



xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs







*************************************************************************************************
* For so2+ IV: column 2 of Table 2

 ivreghdfe lnso2  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation) Productivity Tariff lnKL if year!=2004, a(indc_firm year)

return scalar exp_t2c1=_b[Export]
return scalar abt_t2c1=_b[Abatement_so2]
return scalar tfp_t2c1=_b[Productivity]
return scalar tar_t2c1=_b[Tariff]
return scalar klr_t2c1=_b[lnKL]


ivreghdfe lnso2_d  (exp_dummy2 so2_new1_d= treatment_tfp treatment_so2  ventilation)  ///
 tfp_acf_new_d lntariff_d lnkl_d, a(cic prov year ownership lndust_ini)

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1_d]
return scalar tfp_t2c2=_b[tfp_acf_new_d]
return scalar tar_t2c2=_b[lntariff_d]
return scalar klr_t2c2=_b[lnkl_d]



 ivreghdfe lndust  (Export Abatement_dust= tariff_prod ventilation_prod  ventilation) Productivity Tariff lnKL if year!=2004, a(indc_firm year)

return scalar exp_t2c3=_b[Export]
return scalar abt_t2c3=_b[Abatement_dust]
return scalar tfp_t2c3=_b[Productivity]
return scalar tar_t2c3=_b[Tariff]
return scalar klr_t2c3=_b[lnKL]

ivreghdfe lndust_d  (exp_dummy2 dust_new1_d= treatment_tfp treatment_dust  ventilation)  ///
 tfp_acf_new_d lntariff_d lnkl_d , a(cic prov year ownership lndust_ini) 
return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1_d]
return scalar tfp_t2c4=_b[tfp_acf_new_d]
return scalar tar_t2c4=_b[lntariff_d]
return scalar klr_t2c4=_b[lnkl_d]


end

capture drop indc2
egen indc2=group(firm year)
drop if indc2==.

*------------------------------------------------------
* Columns (3) (4) (7) and (8) of Table A4
*-------------------------------------------------------

bootstrap   exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  klr_t2c1=r(klr_t2c1) ///
exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) tfp_t3c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)  klr_t2c2=r(klr_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)  klr_t2c3=r(klr_t2c3) ///
exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4), ///
 rep(50)  seed(5) nodrop : prodboot


 
 
 
 
 
 

 
 
 
 ****************************Table A6**********************************************
 
  ****************************Table A6**********************************************
  ****************************Table A6**********************************************
 
  ****************************Table A6**********************************************
 
 

  
 
  clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************
sort firm year
mata DLW_TRANSLOG()
end 
use "D:\Nanjing\2019\pollution2\submission\data\boot_app1",clear

*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------

capture program drop prodboot
program define prodboot, rclass
preserve







xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs





*************************************************************************************************
* For so2+ IV: column 1 of Table 4 in the Appendix
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   ///
TFP1_l lntariff  i.cic i.prov i.year i.ownership, partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c1=_b[exp_dummy2]
return scalar abt_t2c1=_b[so2_new1]
return scalar tfp_t2c1=_b[TFP1_l]
return scalar tar_t2c1=_b[lntariff]


*column 2 of Table 4 in the Appendix
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2 ventilation)   ///
TFP1_l lntariff lntariff lnkl_lag lnso2_ini i.cic i.prov i.year i.ownership , partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1]
return scalar tfp_t2c2=_b[TFP1_l]
return scalar tar_t2c2=_b[lntariff]
return scalar klr_t2c2=_b[lnkl_lag]
return scalar iei_t2c2=_b[lnso2_ini]




************************************************************************************************************************************
* For dust +IV: column 5 of Table 4 in the Appendix
ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust   ventilation) ///
TFP1_l lntariff  i.cic i.prov i.year i.ownership , partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c3=_b[exp_dummy2]
return scalar abt_t2c3=_b[dust_new1]
return scalar tfp_t2c3=_b[TFP1_l]
return scalar tar_t2c3=_b[lntariff]


*column 6 of Table 4 in the Appendix
ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation) ///
 TFP1_l lntariff lntariff lnkl_lag lndust_ini i.cic i.prov i.year i.ownership , partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1]
return scalar tfp_t2c4=_b[TFP1_l]
return scalar tar_t2c4=_b[lntariff]
return scalar klr_t2c4=_b[lnkl_lag]
return scalar iei_t2c4=_b[lndust_ini]


***************************************************************************************************************************************


end

capture drop indc
egen indc=group(firm)
drop if indc==.

*---------------------------------------------
* Columns (1) (2) (5) and (6) of Table A6
*--------------------------------------------
bootstrap  exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  ///
 exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) tfp_t2c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)   klr_t2c2=r(klr_t2c2) iei_t2c2=r(iei_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)   ///
 exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4) iei_t2c4=r(iei_t2c4) ,  ///
 reps(50)  seed(1) nodrop cluster(indc) idcluster(newid): prodboot
 
 
 
 
 
 
 
 
 
 
 
 
 
 ***********************************************************************************
 ***********************************************************************************
 
 **********************************************************************************
 *Part II:  Column 3-4 and Column 7-8 of Table A6
  **********************************************************************************


 clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
 
sort firm year
mata DLW_TRANSLOG()
end 
use  "D:\Nanjing\2019\pollution2\submission\data\boot_app2",clear
*rename party_id frdm

*
*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------
keep if _merge==2|_merge==3
capture program drop prodboot
program define prodboot, rclass
preserve




xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs




*************************************************************************************************
* For so2+ IV: column 2 of Table 2

 ivreghdfe lnso2  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation)  ///
 Productivity_l Tariff lnKL , a(indc_firm  year) 

return scalar exp_t2c1=_b[Export]
return scalar abt_t2c1=_b[Abatement_so2]
return scalar tfp_t2c1=_b[ Productivity_l ]
return scalar tar_t2c1=_b[Tariff]
return scalar klr_t2c1=_b[lnKL]


ivreghdfe lnso2_d  (exp_dummy2 so2_new1_d= treatment_tfp treatment_so2  ventilation)  ///
TFP_d_l lntariff_d lnkl_d , a(cic prov year ownership lndust_ini)

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1_d]
return scalar tfp_t2c2=_b[TFP_d_l]
return scalar tar_t2c2=_b[lntariff_d]
return scalar klr_t2c2=_b[lnkl_d]


 ivreghdfe lndust  (Export Abatement_dust= tariff_prod ventilation_prod  ventilation)  ///
 Productivity_l Tariff lnKL , a(indc_firm  year) 
 
return scalar exp_t2c3=_b[Export]
return scalar abt_t2c3=_b[Abatement_dust]
return scalar tfp_t2c3=_b[Productivity_l  ]
return scalar tar_t2c3=_b[Tariff]
return scalar klr_t2c3=_b[lnKL]

ivreghdfe lndust_d  (exp_dummy2 dust_new1_d= treatment_tfp treatment_dust  ventilation)  ///
TFP_d_l lntariff_d lnkl_d , a(cic prov year ownership lndust_ini) 
return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1_d]
return scalar tfp_t2c4=_b[TFP_d_l]
return scalar tar_t2c4=_b[lntariff_d]
return scalar klr_t2c4=_b[lnkl_d]


end

capture drop indc2
egen indc2=group(firm year)
drop if indc2==.


 **********************************************************************************
*The following codes generate Column 3-4 and Column 7-8 of Table A6
  **********************************************************************************

bootstrap   exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  klr_t2c1=r(klr_t2c1) ///
exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) tfp_t3c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)  klr_t2c2=r(klr_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)  klr_t2c3=r(klr_t2c3) ///
exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4), ///
 rep(50)  seed(5) nodrop : prodboot
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 ***********************    Table A7    ****************************************************
 ***********************    Table A7    ****************************************************
 ***********************    Table A7    ****************************************************
 ***********************    Table A7    ****************************************************
 
 
  *-----------------------------------------------------
 * Part II: columns 1-2 and 5-6 of Table A7
*-----------------------------------------------------
 
 
  clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************
sort firm year
mata DLW_TRANSLOG()
end 
use "D:\Nanjing\2019\pollution2\submission\data\boot_app1",clear

replace dust_new1=dust_new2
*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------

capture program drop prodboot
program define prodboot, rclass
preserve







xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs





*************************************************************************************************
* For so2+ IV: column 1 of Table 4 in the Appendix
ivreg2 lnso2  (exp_dummy2 so2_new1 exp_tfp abt_so2_exp= treatment_tfp treatment_so2  IV1 IV2)   ///
tfp_acf_new lntariff  i.cic i.prov i.year i.ownership, partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c1=_b[exp_dummy2]
return scalar abt_t2c1=_b[so2_new1]
return scalar interexp_t2c1=_b[exp_tfp]
return scalar interabt_t2c1=_b[abt_so2_exp]
return scalar tfp_t2c1=_b[tfp_acf_new]
return scalar tar_t2c1=_b[lntariff]


*column 2 of Table 4 in the Appendix
ivreg2 lnso2  (exp_dummy2 so2_new1 exp_tfp abt_so2_exp= treatment_tfp treatment_so2 IV1 IV2)   ///
tfp_acf_new lntariff lntariff lnkl_lag lnso2_ini i.cic i.prov i.year i.ownership , partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1]
return scalar interexp_t2c2=_b[exp_tfp]
return scalar interabt_t2c2=_b[abt_so2_exp]
return scalar tfp_t2c2=_b[tfp_acf_new]
return scalar tar_t2c2=_b[lntariff]
return scalar klr_t2c2=_b[lnkl_lag]
return scalar iei_t2c2=_b[lnso2_ini]




************************************************************************************************************************************
* For dust +IV: column 5 of Table 4 in the Appendix
ivreg2 lndust  (exp_dummy2 dust_new1 exp_tfp abt_dust_exp= treatment_tfp treatment_dust   IV1 IV2) ///
tfp_acf_new lntariff  i.cic i.prov i.year i.ownership , partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c3=_b[exp_dummy2]
return scalar abt_t2c3=_b[dust_new1]
return scalar interexp_t2c3=_b[exp_tfp]
return scalar interabt_t2c3=_b[abt_dust_exp]
return scalar tfp_t2c3=_b[tfp_acf_new]
return scalar tar_t2c3=_b[lntariff]


*column 6 of Table 4 in the Appendix
ivreg2 lndust  (exp_dummy2 dust_new1 exp_tfp abt_dust_exp= treatment_tfp treatment_dust IV1 IV2) ///
tfp_acf_new lntariff lntariff lnkl_lag lndust_ini i.cic i.prov i.year i.ownership , partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1]
return scalar interexp_t2c4=_b[exp_tfp]
return scalar interabt_t2c4=_b[abt_dust_exp]
return scalar tfp_t2c4=_b[tfp_acf_new]
return scalar tar_t2c4=_b[lntariff]
return scalar klr_t2c4=_b[lnkl_lag]
return scalar iei_t2c4=_b[lndust_ini]


***************************************************************************************************************************************


end

capture drop indc
egen indc=group(firm)
drop if indc==.
*------------------------------------------------
* Columns (1) (2) (5) and (6) of Table A7
*--------------------------------------------------
bootstrap  exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) interexp_t2c1=r(interexp_t2c1) interabt_t2c1=r(interabt_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  ///
 exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) interexp_t2c2=r(interexp_t2c2) interabt_t2c2=r(interabt_t2c2) tfp_t2c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)   klr_t2c2=r(klr_t2c2) iei_t2c2=r(iei_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) interexp_t2c3=r(interexp_t2c3) interabt_t2c3=r(interabt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)   ///
 exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) interexp_t2c4=r(interexp_t2c4) interabt_t2c4=r(interabt_t2c4)tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4) iei_t2c4=r(iei_t2c4) ,  ///
 reps(50)  seed(1) nodrop cluster(indc) idcluster(newid): prodboot
 
 
 
 
 
 
 
 
 *************************************************************************
 ****************************************************************************
 *-----------------------------------------------------
 * Part II: columns 3-4 and 7-8 of Table A7
*-----------------------------------------------------
 clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
 
sort firm year
mata DLW_TRANSLOG()
end 
use "D:\Nanjing\2019\pollution2\submission\data\boot_app2",clear

replace IV1=IV111
*
*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------
keep if _merge==2|_merge==3
capture program drop prodboot
program define prodboot, rclass
preserve




xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs




*************************************************************************************************


* For so2+ IV: column 4 of Table 4 in the Appendix
ivreghdfe lnso2 (Export Abatement_so2 exp_tfp_firm abt_so2_exp_firm= tariff_prod ventilation_prod ventilation IV1_firm IV2_firm)   ///
Productivity Tariff lnKL, a(indc_firm year)
 
  

return scalar exp_t2c1=_b[Export]
return scalar abt_t2c1=_b[Abatement_so2]
return scalar interexp_t2c1=_b[exp_tfp_firm]
return scalar interabt_t2c1=_b[abt_so2_exp_firm]
return scalar tfp_t2c1=_b[Productivity]
return scalar tar_t2c1=_b[Tariff]
return scalar klr_t2c1=_b[lnKL]



ivreghdfe lnso2_d  (exp_dummy2 so2_new1 exp_tfp abt_so2_exp= treatment_tfp treatment_so2  ventilation IV1 IV2)  ///
tfp_acf_new_d lntariff_d lnkl_d , a(cic prov year ownership )

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1]
return scalar interexp_t2c2=_b[exp_tfp]
return scalar interabt_t2c2=_b[abt_so2_exp]
return scalar tfp_t2c2=_b[tfp_acf_new_d]
return scalar tar_t2c2=_b[lntariff_d]
return scalar klr_t2c2=_b[lnkl_d]


ivreghdfe lndust  (Export Abatement_dust exp_tfp_firm abt_dust_exp_firm= tariff_prod ventilation_prod ventilation IV1_firm IV2_firm)   ///
Productivity Tariff lnKL, a(indc_firm year)
 
  


return scalar exp_t2c3=_b[Export]
return scalar abt_t2c3=_b[Abatement_dust]
return scalar interexp_t2c3=_b[exp_tfp_firm]
return scalar interabt_t2c3=_b[abt_dust_exp_firm]
return scalar tfp_t2c3=_b[Productivity]
return scalar tar_t2c3=_b[Tariff]
return scalar klr_t2c3=_b[lnKL]

ivreghdfe lndust_d  (exp_dummy2 dust_new1 exp_tfp abt_dust_exp= treatment_tfp treatment_dust  ventilation IV1 IV2)  ///
tfp_acf_new_d lntariff_d lnkl_d , a(cic prov year ownership ) 

return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1]
return scalar interexp_t2c4=_b[exp_tfp]
return scalar interabt_t2c4=_b[abt_dust_exp]
return scalar tfp_t2c4=_b[tfp_acf_new_d]
return scalar tar_t2c4=_b[lntariff_d]
return scalar klr_t2c4=_b[lnkl_d]


end

capture drop indc2
egen indc2=group(firm year)
drop if indc2==.



 *----------------------------------------------------------
 * The following codes generate columns 3 4 7 8 of Table A7
*-----------------------------------------------------------
bootstrap   exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) interexp_t2c1=r(interexp_t2c1) interabt_t2c1=r(interabt_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  klr_t2c1=r(klr_t2c1) ///
exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) interexp_t2c2=r(interexp_t2c2) interabt_t2c2=r(interabt_t2c2) tfp_t3c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)  klr_t2c2=r(klr_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) interexp_t2c3=r(interexp_t2c3) interabt_t2c3=r(interabt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)  klr_t2c3=r(klr_t2c3) ///
exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) interexp_t2c4=r(interexp_t2c4) interabt_t2c4=r(interabt_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4), ///
 rep(50)  seed(5) nodrop : prodboot

 *--------------------------------------------------------------------------------------------------
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 ***********************    Table A8    ****************************************************
 ***********************    Table A8    ****************************************************
 ***********************    Table A8    ****************************************************
 ***********************    Table A8    ****************************************************
 
 
 
 
 
 

 clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************
sort firm year
mata DLW_TRANSLOG()
end 
use "D:\Nanjing\2019\pollution2\submission\data\boot_app1",clear
*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------

capture program drop prodboot
program define prodboot, rclass
preserve






* Re-estimate firm-level production function for each sample from bootstrap

xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs







*************************************************************************************************
* For so2+ IV: column 2 of Table 2
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   ///
 lnso2_lag tfp_acf_new lntariff  i.cic i.prov i.year i.ownership, partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c1=_b[exp_dummy2]
return scalar abt_t2c1=_b[so2_new1]
return scalar ems_t2c1=_b[lnso2_lag]
return scalar tfp_t2c1=_b[tfp_acf_new]
return scalar tar_t2c1=_b[lntariff]


ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   ///
lnso2_lag tfp_acf_new lntariff lnkl_lag lnso2_ini i.cic i.prov i.year i.ownership, partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1]
return scalar ems_t2c2=_b[lnso2_lag]
return scalar tfp_t2c2=_b[tfp_acf_new]
return scalar tar_t2c2=_b[lntariff]
return scalar klr_t2c2=_b[lnkl_lag]
return scalar iei_t2c2=_b[lnso2_ini]


************************************************************************************************************************************
* For dust +IV: column 4 of Table 2
ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation) ///
lndust_lag tfp_acf_new lntariff  i.cic i.prov i.year i.ownership, partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c3=_b[exp_dummy2]
return scalar abt_t2c3=_b[dust_new1]
return scalar ems_t2c3=_b[lndust_lag]
return scalar tfp_t2c3=_b[tfp_acf_new]
return scalar tar_t2c3=_b[lntariff]


ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation) ///
lndust_lag tfp_acf_new lntariff lnkl_lag lndust_ini i.cic i.prov i.year i.ownership, partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1]
return scalar ems_t2c4=_b[lndust_lag]
return scalar tfp_t2c4=_b[tfp_acf_new]
return scalar tar_t2c4=_b[lntariff]
return scalar klr_t2c4=_b[lnkl_lag]
return scalar iei_t2c4=_b[lndust_ini]


***************************************************************************************************************************************


end

capture drop indc
egen indc=group(firm)
drop if indc==.

*---------------------------------------------------------------
*  columns 1-2 and 5-6 of Table A8
*------------------------------------------------------------------

bootstrap  exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) ems_t2c1=r(ems_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  ///
 exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) ems_t2c2=r(ems_t2c2) tfp_t2c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)   klr_t2c2=r(klr_t2c2)  iei_t2c2=r(iei_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) ems_t2c3=r(ems_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)   ///
 exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) ems_t2c4=r(ems_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)    klr_t2c4=r(klr_t2c4) iei_t2c4=r(iei_t2c4),  ///
 reps(50)  seed(1) nodrop cluster(indc) idcluster(newid): prodboot
 
 *------------------------------------------------------------------------------------
 
 
 
 
 
 
 
 
 *---------------------------------------------------------------
 * Part II:  columns 3-4 and 7-8 of Table A8
*------------------------------------------------------------------
 clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
 
sort firm year
mata DLW_TRANSLOG()
end 
use "D:\Nanjing\2019\pollution2\submission\data\boot_app2",clear
replace IV1=IV111
replace  so2_new1=SO2_NEW1 
replace dust_new1=DUST_NEW1 
*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------
keep if _merge==2|_merge==3
capture program drop prodboot
program define prodboot, rclass
preserve




xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs




*************************************************************************************************


* For so2+ IV: column 4 of Table 4 in the Appendix
ivreghdfe lnso2 (Export Abatement_so2 = tariff_prod ventilation_prod ventilation )   ///
lnso2_lag Productivity Tariff lnKL, a(indc_firm year)
 
  

return scalar exp_t2c1=_b[Export]
return scalar abt_t2c1=_b[Abatement_so2]
return scalar ems_t2c1=_b[lnso2_lag]
return scalar tfp_t2c1=_b[Productivity]
return scalar tar_t2c1=_b[Tariff]
return scalar klr_t2c1=_b[lnKL]



ivreghdfe lnso2_d  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation )  ///
lnso2_lag tfp_acf_new_d lntariff_d lnkl_d if year!=2004&merge2==3, a(cic prov year ownership )

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1]
return scalar ems_t2c2=_b[lnso2_lag]
return scalar tfp_t2c2=_b[tfp_acf_new_d]
return scalar tar_t2c2=_b[lntariff_d]
return scalar klr_t2c2=_b[lnkl_d]


ivreghdfe lndust  (Export Abatement_dust = tariff_prod ventilation_prod ventilation )   ///
lndust_lag Productivity Tariff lnKL , a(indc_firm year)
 
  


return scalar exp_t2c3=_b[Export]
return scalar abt_t2c3=_b[Abatement_dust]
return scalar ems_t2c3=_b[lndust_lag]
return scalar tfp_t2c3=_b[Productivity]
return scalar tar_t2c3=_b[Tariff]
return scalar klr_t2c3=_b[lnKL]

ivreghdfe lndust_d  (exp_dummy2 dust_new1 = treatment_tfp treatment_dust  ventilation )  ///
lndust_lag tfp_acf_new_d lntariff_d lnkl_d if year!=2004&merge2==3, a(cic prov year ownership ) 

return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1]
return scalar ems_t2c4=_b[lndust_lag]
return scalar tfp_t2c4=_b[tfp_acf_new_d]
return scalar tar_t2c4=_b[lntariff_d]
return scalar klr_t2c4=_b[lnkl_d]


end

capture drop indc2
egen indc2=group(firm year)
drop if indc2==.

*-------------------------------------------
* Colums (3) (4) (7) (8) of Table A8
*------------------------------------------
bootstrap   exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1)  ems_t2c1=r(ems_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  klr_t2c1=r(klr_t2c1) ///
exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2)  ems_t2c2=r(ems_t2c2) tfp_t3c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)  klr_t2c2=r(klr_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3)   ems_t2c3=r(ems_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)  klr_t2c3=r(klr_t2c3) ///
exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4)  ems_t2c4=r(ems_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4), ///
 rep(50)  seed(5) nodrop : prodboot

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 ***************************Table A9********************************************
 ***************************Table A9********************************************
 ***************************Table A9********************************************
 ***************************Table A9********************************************
 
 
 
  *-------------------------------------------
* Colums (1) (2) (5) (6) of Table A9
*------------------------------------------
 
 


 clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************
sort firm year
mata DLW_TRANSLOG()
end 


use "D:\Nanjing\2019\pollution2\submission\data\boot_app3",clear


*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------

capture program drop prodboot
program define prodboot, rclass
preserve






* Re-estimate firm-level production function for each sample from bootstrap

xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* downer* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs







*************************************************************************************************
* For so2+ IV: column 2 of Table 2
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   ///
 Productivity lntariff  i.cic i.prov i.year i.ownership if  _merge==3, partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c1=_b[exp_dummy2]
return scalar abt_t2c1=_b[so2_new1]
return scalar tfp_t2c1=_b[Productivity]
return scalar tar_t2c1=_b[lntariff]


ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   ///
 Productivity  lntariff lnkl_lag lnso2_ini i.cic i.prov i.year i.ownership  if  _merge==3, partial(i.cic i.prov i.year) cluster (prov_c)
 
return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1]
return scalar tfp_t2c2=_b[Productivity]
return scalar tar_t2c2=_b[lntariff]
return scalar klr_t2c2=_b[lnkl_lag]
return scalar iei_t2c2=_b[lnso2_ini]


************************************************************************************************************************************
* For dust +IV: column 4 of Table 2
ivreg2 lndust  (exp_dummy2 Abatement_dust= treatment_tfp treatment_dust  ventilation) ///
 Productivity lntariff  i.cic i.prov i.year i.ownership, partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c3=_b[exp_dummy2]
return scalar abt_t2c3=_b[Abatement_dust]
return scalar tfp_t2c3=_b[Productivity]
return scalar tar_t2c3=_b[lntariff]


ivreg2 lndust  (exp_dummy2 Abatement_dust= treatment_tfp treatment_dust  ventilation) ///
Productivity lntariff lnkl_lag lndust_ini i.cic i.prov i.year i.ownership  if  _merge==3, partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[Abatement_dust]
return scalar tfp_t2c4=_b[Productivity]
return scalar tar_t2c4=_b[lntariff]
return scalar klr_t2c4=_b[lnkl_lag]
return scalar iei_t2c4=_b[lndust_ini]


***************************************************************************************************************************************


end

capture drop indc
egen indc=group(firm)
drop if indc==.



bootstrap  exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1)  tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  ///
 exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2)  tfp_t2c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)   klr_t2c2=r(klr_t2c2)  iei_t2c2=r(iei_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)   ///
 exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4)  tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)    klr_t2c4=r(klr_t2c4) iei_t2c4=r(iei_t2c4),  ///
 reps(50)  seed(1) nodrop cluster(indc) idcluster(newid): prodboot
 
 
 
 ***************************************************************************************
 
 *-------------------------------------------
* Colums (3) (4) (7) (8) of Table A9
*------------------------------------------
 
 clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************
sort firm year
mata DLW_TRANSLOG()
end 


use "D:\Nanjing\2019\pollution2\submission\data\boot_app4",clear

*******************************

capture program drop prodboot
program define prodboot, rclass
preserve




xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* downer* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs




*************************************************************************************************



ivreghdfe lnso2_firm (Export Abatement_so2_firm = tariff_prod ventilation_prod ventilation )   ///
Productivity_firm Tariff lnKL , a(indc_firm year)
 
  

return scalar exp_t2c1=_b[Export]
return scalar abt_t2c1=_b[Abatement_so2_firm]
return scalar tfp_t2c1=_b[Productivity_firm]
return scalar tar_t2c1=_b[Tariff]
return scalar klr_t2c1=_b[lnKL]



ivreghdfe lnso2_d  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation )  ///
 tfp_acf_new_d lntariff_d lnkl_d if merge2==3, a(cic prov year ownership )

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1]
return scalar tfp_t2c2=_b[tfp_acf_new_d]
return scalar tar_t2c2=_b[lntariff_d]
return scalar klr_t2c2=_b[lnkl_d]


ivreghdfe lndust_firm  (Export Abatement_dust_firm = tariff_prod ventilation_prod ventilation )   ///
 Productivity_firm Tariff lnKL , a(indc_firm year)
 
  


return scalar exp_t2c3=_b[Export]
return scalar abt_t2c3=_b[Abatement_dust_firm]
return scalar tfp_t2c3=_b[Productivity_firm]
return scalar tar_t2c3=_b[Tariff]
return scalar klr_t2c3=_b[lnKL]

ivreghdfe lndust_d  (exp_dummy2 Abatement_dust = treatment_tfp treatment_dust  ventilation )  ///
tfp_acf_new_d lntariff_d lnkl_d if merge2==3, a(cic prov year ownership ) 

return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[Abatement_dust]
return scalar tfp_t2c4=_b[tfp_acf_new_d]
return scalar tar_t2c4=_b[lntariff_d]
return scalar klr_t2c4=_b[lnkl_d]


end

capture drop indc2
egen indc2=group(firm year)
drop if indc2==.


 *------------------------------------------------------------
*Following codes generate: Colums (3) (4) (7) (8) of Table A9
*-------------------------------------------------------------
bootstrap   exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1)   tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  klr_t2c1=r(klr_t2c1) ///
exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2)  tfp_t3c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)  klr_t2c2=r(klr_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3)    tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)  klr_t2c3=r(klr_t2c3) ///
exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4)  tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4), ///
 rep(50)  seed(5) nodrop : prodboot

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 








*******************************************   Table A10   ************************************************************************************
*******************************************   Table A10   ************************************************************************************
*******************************************   Table A10   ************************************************************************************
*******************************************   Table A10   ************************************************************************************


clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************
sort firm year
mata DLW_TRANSLOG()
end 
use "D:\Nanjing\2019\pollution2\submission\data\boot1",clear
rename frdm firm
gen hangye=int(cic_adj/100)
drop if hangye<13
drop if hangye>42

*keep if hangye==27|hangye==14
capture drop cic2
capture drop cic4 
gen cic2=floor(cic_adj/100)
egen gcic4=group(cic_adj)
egen SDcic=sd(cic2), by(firm)
* do "/gpfs52/home/tany2/for accre/do file/tfp_combine_accre.do"

*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------

capture program drop prodboot
program define prodboot, rclass
preserve






* Re-estimate firm-level production function for each sample from bootstrap
do "D:\Nanjing\2019\pollution2\do file\for accre\do file\tfp_combine.do"

xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs



replace ownerships=0 if ownerships==.


* For so2 + SOE: column 1 of Table 3
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)  ///
 tfp_acf_new lntariff lnkl_lag lnso2_ini i.cic i.prov i.year if ownerships==1|ownerships==2, partial(i.cic i.prov i.year) cluster (prov_c)


return scalar exp_t2c1=_b[exp_dummy2]
return scalar abt_t2c1=_b[so2_new1]
return scalar tfp_t2c1=_b[tfp_acf_new]
return scalar tar_t2c1=_b[lntariff]
return scalar klr_t2c1=_b[lnkl_lag]
return scalar iei_t2c1=_b[lnso2_ini]
********************************************************************************************************

* For so2 + private: column 2 of Table 3
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)  ///
 tfp_acf_new lntariff lnkl_lag lnso2_ini i.cic i.prov i.year if ownerships==3, partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1]
return scalar tfp_t2c2=_b[tfp_acf_new]
return scalar tar_t2c2=_b[lntariff]
return scalar klr_t2c2=_b[lnkl_lag]
return scalar iei_t2c2=_b[lnso2_ini]
************************************************************************************************************************************

* For so2+foreign: column 3 of Table 3
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   ///
tfp_acf_new lntariff lnkl_lag lnso2_ini i.cic i.prov i.year if ownerships==4|ownerships==5, partial(i.cic i.prov i.year) cluster (prov_c)

return scalar exp_t2c3=_b[exp_dummy2]
return scalar abt_t2c3=_b[so2_new1]
return scalar tfp_t2c3=_b[tfp_acf_new]
return scalar tar_t2c3=_b[lntariff]
return scalar klr_t2c3=_b[lnkl_lag]
return scalar iei_t2c3=_b[lnso2_ini]
***************************************************************************************************************************************
* For dust+SOE: column 4 of Table 3

ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation) ///
  tfp_acf_new lntariff lnkl_lag lndust_ini i.cic i.prov i.year if ownerships==1|ownerships==2, partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1]
return scalar tfp_t2c4=_b[tfp_acf_new]
return scalar tar_t2c4=_b[lntariff]
return scalar klr_t2c4=_b[lnkl_lag]
return scalar iei_t2c4=_b[lndust_ini]
*****************************************************************************************************************************************

* For dust+private: column 5 of of Table 3

ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation)  ///
tfp_acf_new lntariff lnkl_lag lndust_ini i.cic i.prov i.year if ownerships==3, partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c5=_b[exp_dummy2]
return scalar abt_t2c5=_b[dust_new1]
return scalar tfp_t2c5=_b[tfp_acf_new]
return scalar tar_t2c5=_b[lntariff]
return scalar klr_t2c5=_b[lnkl_lag]
return scalar iei_t2c5=_b[lndust_ini]

***************************************************************************************************************************************************
* For dust+foreign: column 6 of Table 3
ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation) ///
  tfp_acf_new lntariff lnkl_lag lndust_ini i.cic i.prov i.year if ownerships==4|ownerships==5, partial(i.cic i.prov i.year ) cluster (prov_c)

return scalar exp_t2c6=_b[exp_dummy2]
return scalar abt_t2c6=_b[dust_new1]
return scalar tfp_t2c6=_b[tfp_acf_new]
return scalar tar_t2c6=_b[lntariff]
return scalar klr_t2c6=_b[lnkl_lag]
return scalar iei_t2c6=_b[lndust_ini]

end

capture drop indc
egen indc=group(firm)
drop if indc==.

*-------------------------------------------------------------------------------------------------------------------------
* The following codes generate columns 1-6 of Table A10
*--------------------------------------------------------------------------------------------------------------------------

bootstrap  exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  klr_t2c1=r(klr_t2c1) iei_t2c1=r(iei_t2c1) ///
 exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) tfp_t2c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)  klr_t2c2=r(klr_t2c2) iei_t2c2=r(iei_t2c2)  ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)  klr_t2c3=r(klr_t2c3) iei_t2c3=r(iei_t2c3)  ///
 exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4) iei_t2c4=r(iei_t2c4)  ///
 exp_t2c5=r(exp_t2c5) abt_t2c5=r(abt_t2c5) tfp_t2c5=r(tfp_t2c5) tar_t2c5=r(tar_t2c5)  klr_t2c5=r(klr_t2c5) iei_t2c5=r(iei_t2c5)  ///
 exp_t2c6=r(exp_t2c6) abt_t2c6=r(abt_t2c6) tfp_t2c6=r(tfp_t2c6) tar_t2c6=r(tar_t2c6)  klr_t2c6=r(klr_t2c6) iei_t2c6=r(iei_t2c6), ///
 reps(50)  seed(1) nodrop cluster(indc) idcluster(newid): prodboot


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 *********************************   Table A11    *************************************************************
 *********************************   Table A11     *************************************************************
 *********************************   Table A11     *************************************************************
 *********************************   Table A11     *************************************************************
 
 
 
 
 

   clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************
sort firm year
mata DLW_TRANSLOG()
end 
use "D:\Nanjing\2019\pollution2\submission\data\boot1",clear
rename frdm firm
gen hangye=int(cic_adj/100)
drop if hangye<13
drop if hangye>42

*keep if hangye==27
capture drop cic2
capture drop cic4 
gen cic2=floor(cic_adj/100)
egen gcic4=group(cic_adj)
egen SDcic=sd(cic2), by(firm)
 *do "D:\Nanjing\2019\pollution2\do file\for accre\do file\tfp_combine.do"
 
*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------


capture program drop prodboot
program define prodboot, rclass
preserve


do "D:\Nanjing\2019\pollution2\do file\for accre\do file\tfp_combine.do"


xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs

*****************************************************************************************************



capture drop coast
gen coast=0
replace coast=1 if prov==51|prov==21|prov==13|prov==11|prov==22|prov==37|prov==32|prov==22|prov==33|prov==35|prov==44|prov==45|prov==46/*coast=1 if a province is a coastal province*/

* For so2+ coast: column 1 of Table 4
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   tfp_acf_new lntariff lnkl_lag lnso2_ini  ///
i.cic i.prov i.year i.ownerships if coast==1, partial(i.cic i.prov i.year i.ownership) cluster (prov_c)
return scalar exp_t2c1=_b[exp_dummy2]
return scalar abt_t2c1=_b[so2_new1]
return scalar tfp_t2c1=_b[tfp_acf_new]
return scalar tar_t2c1=_b[lntariff]
return scalar klr_t2c1=_b[lnkl_lag]
return scalar iei_t2c1=_b[lnso2_ini]

*************************************************************************
* For so2+ noncoast: column 2 of Table 4
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   tfp_acf_new lntariff lnkl_lag lnso2_ini  ///
i.cic i.prov i.year i.ownerships if coast==0, partial(i.cic i.prov i.year i.ownership) cluster (prov_c)


return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1]
return scalar tfp_t2c2=_b[tfp_acf_new]
return scalar tar_t2c2=_b[lntariff]
return scalar klr_t2c2=_b[lnkl_lag]
return scalar iei_t2c2=_b[lnso2_ini]
*-------------------------------------------------------------------------------------------------------------

*for dust+ coast: column 5 of Table 4
ivreghdfe lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation)   tfp_acf_new lntariff lnkl_lag lndust_ini ///
i.cic i.prov i.year i.ownerships if coast==1, partial(i.cic i.prov i.year i.ownership)  cluster (prov_c)
return scalar exp_t2c3=_b[exp_dummy2]
return scalar abt_t2c3=_b[dust_new1]
return scalar tfp_t2c3=_b[tfp_acf_new]
return scalar tar_t2c3=_b[lntariff]
return scalar klr_t2c3=_b[lnkl_lag]
return scalar iei_t2c3=_b[lndust_ini]
*--------------------------------------------------------------------------------------------------------
* for dust+ non-coast: column 6 of Table 4
ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation)   tfp_acf_new lntariff lnkl_lag lndust_ini ///
i.cic i.prov i.year i.ownerships if coast==0, partial(i.cic i.prov i.year i.ownership)  cluster (prov_c)
return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1]
return scalar tfp_t2c4=_b[tfp_acf_new]
return scalar tar_t2c4=_b[lntariff]
return scalar klr_t2c4=_b[lnkl_lag]
return scalar iei_t2c4=_b[lndust_ini]

*------------------------------------------------------------------------------------------------------------------------

*Note:  7.483833 is the median ventilation coefficient at province leve: first calculate the province-level median of ventilation over years (prov_ventilation), and then calculate the 
*       the median of prov_ventilation

*for so2+high-mix: column 3 of Table 4
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   tfp_acf_new lntariff lnkl_lag lnso2_ini ///
i.cic i.prov i.year i.ownerships  if ventilation> 7.483833, partial(i.cic i.prov i.year i.ownership) cluster (prov_c)
return scalar exp_t2c5=_b[exp_dummy2]
return scalar abt_t2c5=_b[so2_new1]
return scalar tfp_t2c5=_b[tfp_acf_new]
return scalar tar_t2c5=_b[lntariff]
return scalar klr_t2c5=_b[lnkl_lag]
return scalar iei_t2c5=_b[lnso2_ini]
*----------------------------------------------------------------------------------------
*for so2+low-mix: column 4 of Table 4
ivreg2 lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   tfp_acf_new lntariff lnkl_lag lnso2_ini  ///
i.cic i.prov i.year i.ownerships if ventilation<= 7.483833, partial(i.cic i.prov i.year i.ownership) cluster (prov_c)
return scalar exp_t2c6=_b[exp_dummy2]
return scalar abt_t2c6=_b[so2_new1]
return scalar tfp_t2c6=_b[tfp_acf_new]
return scalar tar_t2c6=_b[lntariff]
return scalar klr_t2c6=_b[lnkl_lag]
return scalar iei_t2c6=_b[lnso2_ini]

*------------------------------------------------------------------------------------------
* for dust+ high-mix: column 7 of Table 4
ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation)   tfp_acf_new lntariff lnkl_lag lndust_ini ///
i.cic i.prov i.year i.ownerships if ventilation>  7.483833, partial(i.cic i.prov i.year i.ownership)  cluster (prov_c)
return scalar exp_t2c7=_b[exp_dummy2]
return scalar abt_t2c7=_b[dust_new1]
return scalar tfp_t2c7=_b[tfp_acf_new]
return scalar tar_t2c7=_b[lntariff]
return scalar klr_t2c7=_b[lnkl_lag]
return scalar iei_t2c7=_b[lndust_ini]
*---------------------------------------------------------------------------------------------
* for dust+low-mix: column 8 of Table 4

ivreg2 lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation)   tfp_acf_new lntariff lnkl_lag lndust_ini ///
i.cic i.year i.ownerships i.prov if ventilation<  7.483833, partial(i.cic i.prov i.year i.ownership)  cluster (prov_c)
return scalar exp_t2c8=_b[exp_dummy2]
return scalar abt_t2c8=_b[dust_new1]
return scalar tfp_t2c8=_b[tfp_acf_new]
return scalar tar_t2c8=_b[lntariff]
return scalar klr_t2c8=_b[lnkl_lag]
return scalar iei_t2c8=_b[lndust_ini]

*--------------------------------------------------------------------------------------
 
drop exp_dummy2 tfp_acf_new
end

capture drop indc
egen indc=group(firm)
drop if indc==.

*-------------------------------------------------------------------------------------------------------------------------
* The following codes generate columns 1-8 of Table A11
*------------------------------------------------------------------------------------------------------------------------------

 bootstrap  exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  klr_t2c1=r(klr_t2c1) iei_t2c1=r(iei_t2c1) ///
 exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) tfp_t2c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)  klr_t2c2=r(klr_t2c2) iei_t2c2=r(iei_t2c2) ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)  klr_t2c3=r(klr_t2c3) iei_t2c3=r(iei_t2c3) ///
 exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4) iei_t2c4=r(iei_t2c4) ///
 exp_t2c5=r(exp_t2c5) abt_t2c5=r(abt_t2c5) tfp_t2c5=r(tfp_t2c5) tar_t2c5=r(tar_t2c5)  klr_t2c5=r(klr_t2c5) iei_t2c5=r(iei_t2c5) ///
 exp_t2c6=r(exp_t2c6) abt_t2c6=r(abt_t2c6) tfp_t2c6=r(tfp_t2c6) tar_t2c6=r(tar_t2c6)  klr_t2c6=r(klr_t2c6) iei_t2c6=r(iei_t2c6) ///
  exp_t2c7=r(exp_t2c7) abt_t2c7=r(abt_t2c7) tfp_t2c7=r(tfp_t2c7) tar_t2c7=r(tar_t2c7)  klr_t2c7=r(klr_t2c7) iei_t2c7=r(iei_t2c7) ///
   exp_t2c8=r(exp_t2c8) abt_t2c8=r(abt_t2c8) tfp_t2c8=r(tfp_t2c8) tar_t2c8=r(tar_t2c8)  klr_t2c8=r(klr_t2c8) iei_t2c8=r(iei_t2c8), ///
 reps(50)  seed(1) nodrop cluster(indc) idcluster(newid): prodboot


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  ********************************    Table A12    **************************************************
 ********************************    Table A12    **************************************************
 ********************************    Table A12    **************************************************
 ********************************    Table A12    **************************************************
 
 
   clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end
***********************************************瑞丽新加的一段，建议上面一段和这一段即从clear mata到end和从capture到end这一段分开依次放入stata中
capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************
sort firm year
mata DLW_TRANSLOG()
end 
use "D:\Nanjing\2019\pollution2\submission\data\boot_app5",clear

*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------

capture program drop prodboot
program define prodboot, rclass
preserve





xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs


egen owner_y=group(ownerships year)
egen prov_y=group(prov year)




* For so2+initial-nonexporter: column 1 of Table 5
ivreghdfe lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation )   ///
tfp_acf_new lntariff lnkl_lag   lnso2_ini if switch==1, a(cic prov year ownership) cluster (prov_c)
est sto so2_IV1

return scalar exp_t2c1=_b[exp_dummy2]
return scalar abt_t2c1=_b[so2_new1]
return scalar tfp_t2c1=_b[tfp_acf_new]
return scalar tar_t2c1=_b[lntariff]
return scalar klr_t2c1=_b[lnkl_lag]
return scalar iei_t2c1=_b[lnso2_ini]
*---------------------------------------------------------------------------------------------------------
* for dust+initial-nonexporter: column 5 of Table 5
ivreghdfe lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation dust_new2)  ///
 tfp_acf_new lntariff lnkl_lag lndust_ini if  switch==1, a(cic prov year ownership) cluster (prov_c)
est sto dust_IV1
return scalar exp_t2c4=_b[exp_dummy2]
return scalar abt_t2c4=_b[dust_new1]
return scalar tfp_t2c4=_b[tfp_acf_new]
return scalar tar_t2c4=_b[lntariff]
return scalar klr_t2c4=_b[lnkl_lag]
return scalar iei_t2c4=_b[lndust_ini]

*-------------------------------------------------------------------------------------------

* for so2+diff-trend(1): column 2 of Table 5 
ivreghdfe lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)  ///
 tfp_acf_new lntariff lnkl_lag lnso2_ini, a(cic_y prov  owner_y) cluster (prov_c)
est sto so2_IV1

return scalar exp_t2c2=_b[exp_dummy2]
return scalar abt_t2c2=_b[so2_new1]
return scalar tfp_t2c2=_b[tfp_acf_new]
return scalar tar_t2c2=_b[lntariff]
return scalar klr_t2c2=_b[lnkl_lag]
return scalar iei_t2c2=_b[lnso2_ini]
*-------------------------------------------------------------------------------------------
* for dust+diff-trend(1): column 6 of Table 5 
ivreghdfe lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation) ///
  tfp_acf_new lntariff lnkl_lag lndust_ini , a(cic_y prov  owner_y) cluster (prov_c)
est sto dust_IV1
return scalar exp_t2c5=_b[exp_dummy2]
return scalar abt_t2c5=_b[dust_new1]
return scalar tfp_t2c5=_b[tfp_acf_new]
return scalar tar_t2c5=_b[lntariff]
return scalar klr_t2c5=_b[lnkl_lag]
return scalar iei_t2c5=_b[lndust_ini]


*----------------------------------------------------------------------------------------------------

* for so2+ diff-trend(2): column 3 of Table 5
ivreghdfe lnso2  (exp_dummy2 so2_new1= treatment_tfp treatment_so2  ventilation)   ///
tfp_acf_new lntariff lnkl_lag lnso2_ini, a(cic_y prov_y  owner_y) cluster (prov_c)
est sto so2_IV1

return scalar exp_t2c3=_b[exp_dummy2]
return scalar abt_t2c3=_b[so2_new1]
return scalar tfp_t2c3=_b[tfp_acf_new]
return scalar tar_t2c3=_b[lntariff]
return scalar klr_t2c3=_b[lnkl_lag]
return scalar iei_t2c3=_b[lnso2_ini]
*--------------------------------------------------------------------------------------------------
* for dust+ diff-trend(2): column 7 of Table 5
ivreghdfe lndust  (exp_dummy2 dust_new1= treatment_tfp treatment_dust  ventilation)  ///
 tfp_acf_new lntariff lnkl_lag lndust_ini , a(cic_y prov_y  owner_y) cluster (prov_c)
est sto dust_IV1
return scalar exp_t2c6=_b[exp_dummy2]
return scalar abt_t2c6=_b[dust_new1]
return scalar tfp_t2c6=_b[tfp_acf_new]
return scalar tar_t2c6=_b[lntariff]
return scalar klr_t2c6=_b[lnkl_lag]
return scalar iei_t2c6=_b[lndust_ini]
*----------------------------------------------------------------------------------------------------



end

capture drop indc
egen indc=group(firm)
drop if indc==.

*------------------------------------------------------
*The following codes generate columns 1-6 of Table A12
*------------------------------------------------------
bootstrap  exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  klr_t2c1=r(klr_t2c1) iei_t2c1=r(iei_t2c1)  /// 
exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) tfp_t2c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)  klr_t2c2=r(klr_t2c2) iei_t2c2=r(iei_t2c2)  ///
 exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)  klr_t2c3=r(klr_t2c3) iei_t2c3=r(iei_t2c3)    ///
 exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4)  iei_t2c4=r(iei_t2c4) ///
 exp_t2c5=r(exp_t2c5) abt_t2c5=r(abt_t2c5) tfp_t2c5=r(tfp_t2c5) tar_t2c5=r(tar_t2c5)  klr_t2c5=r(klr_t2c5) iei_t2c5=r(iei_t2c5)  /// 
  exp_t2c6=r(exp_t2c6) abt_t2c6=r(abt_t2c6) tfp_t2c6=r(tfp_t2c6) tar_t2c6=r(tar_t2c6)  klr_t2c6=r(klr_t2c6) iei_t2c6=r(iei_t2c6),  /// 
 reps(50)  seed(1) nodrop cluster(indc) idcluster(newid): prodboot


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 ********************************    Table A23    **************************************************
 ********************************    Table A23    **************************************************
 ********************************    Table A23    **************************************************
 ********************************    Table A23    **************************************************
 
 
   clear mata
   mata:

void GMM_DLW_CD(todo,betas,crit,g,H)
  {
	PHI=st_data(.,("phi"))
	PHI_LAG=st_data(.,("phi_lag"))
	Z=st_data(.,("const","m_lag","l_lag","y1","y2","y3","k","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	X=st_data(.,("const","m","l","x1","x2","x3","k","exp_dummy99","exp_dummy00","exp_dummy01","exp_dummy02","exp_dummy03","exp_dummy04","exp_dummy05"))
	X_lag=st_data(.,("const","m_lag","l_lag","x1_lag","x2_lag","x3_lag","k_lag","exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))
	Y=st_data(.,("q"))
	C=st_data(.,("const"))
	

	EXPORT=st_data(.,("exp_dummy99_lag","exp_dummy00_lag","exp_dummy01_lag","exp_dummy02_lag","exp_dummy03_lag","exp_dummy04_lag","exp_dummy05_lag"))

	OMEGA=PHI-X*betas'
	OMEGA_lag=PHI_LAG-X_lag*betas'
	OMEGA_lag_pol=(C,EXPORT,OMEGA_lag)
	g_b = invsym(OMEGA_lag_pol'OMEGA_lag_pol)*OMEGA_lag_pol'OMEGA 
	XI=OMEGA-OMEGA_lag_pol*g_b /*XI=epsilon: recover epsilon_it in equation (23): shock in productivity;*/
	crit=(Z'XI)'(Z'XI)
  }
///
///
void DLW_TRANSLOG()
	{
	initialvalue=st_data(1,("initialConst","initialm","initiall","initialx1","initialx2","initialx3","initialk","initialexp_dummy99","initialexp_dummy00","initialexp_dummy01","initialexp_dummy02","initialexp_dummy03","initialexp_dummy04","initialexp_dummy05"))
	S=optimize_init()
	optimize_init_evaluator(S, &GMM_DLW_CD())
	optimize_init_evaluatortype(S,"d0")
	optimize_init_technique(S, "nm")
	optimize_init_nmsimplexdeltas(S, 0.1)
	optimize_init_which(S,"min")
	optimize_init_params(S,initialvalue)
	p=optimize(S)
	p
	st_matrix("beta_dlwtranslog",p)
	}
end

capture program drop dlw_translog
program dlw_translog, rclass
preserve
**********************************************

sort firm year
mata DLW_TRANSLOG()
end 

use "D:\Nanjing\2019\pollution2\submission\data\boot_app6",clear

*rename party_id frdm

*
*----------------------------------------------------------------------
* bootstrap starts from here
*----------------------------------------------------------------------
keep if _merge==2|_merge==3
capture program drop prodboot
program define prodboot, rclass
preserve






* Re-estimate firm-level production function for each sample from bootstrap



xi:heckman ratio1 dyear*, noconstant twostep sel(exp_dummy=  tfp_acf_new clean_dummy_so2_lag clean_dummy_dust_lag clean_dummy_cod_lag dcic2* lnv_lag lnkl_lag dprov* owner* dyear*)  

gen coef1_bs=_b[dyear1]
gen coef2_bs=_b[dyear2]
gen coef3_bs=_b[dyear3]
gen coef4_bs=_b[dyear4]
gen coef5_bs=_b[dyear5]
gen coef6_bs=_b[dyear6]
gen coef7_bs=_b[dyear7]
capture drop exp_dummy2
gen exp_dummy2=.
replace exp_dummy2=exp_dummy*coef1_bs*dyear1 if year==1999
replace exp_dummy2=exp_dummy*coef2_bs*dyear2 if year==2000
replace exp_dummy2=exp_dummy*coef3_bs*dyear3 if year==2001
replace exp_dummy2=exp_dummy*coef4_bs*dyear4 if year==2002
replace exp_dummy2=exp_dummy*coef5_bs*dyear5 if year==2003
replace exp_dummy2=exp_dummy*coef6_bs*dyear6 if year==2004
replace exp_dummy2=exp_dummy*coef7_bs*dyear7 if year==2005
drop  coef1_bs coef2_bs coef3_bs coef4_bs coef5_bs coef6_bs coef7_bs







*************************************************************************************************
* For so2+ IV: column 2 of Table 2

 ivreghdfe RD_d  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation) Productivity Tariff lnKL lnso2_ini, a(cic  prov year ownership)

return scalar exp_t2c1=_b[Export]
return scalar abt_t2c1=_b[Abatement_so2]
return scalar tfp_t2c1=_b[Productivity]
return scalar tar_t2c1=_b[Tariff]
return scalar klr_t2c1=_b[lnKL]
return scalar iei_t2c1=_b[lnso2_ini]



 ivreghdfe lnvintage  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation) Productivity Tariff lnKL lnso2_ini, a(cic  prov year ownership)

return scalar exp_t2c2=_b[Export]
return scalar abt_t2c2=_b[Abatement_so2]
return scalar tfp_t2c2=_b[Productivity]
return scalar tar_t2c2=_b[Tariff]
return scalar klr_t2c2=_b[lnKL]
return scalar iei_t2c2=_b[lnso2_ini]



 ivreghdfe NRG  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation) Productivity Tariff lnKL lnso2_ini, a(cic  prov year ownership)

return scalar exp_t2c3=_b[Export]
return scalar abt_t2c3=_b[Abatement_so2]
return scalar tfp_t2c3=_b[Productivity]
return scalar tar_t2c3=_b[Tariff]
return scalar klr_t2c3=_b[lnKL]
return scalar iei_t2c3=_b[lnso2_ini]



 ivreghdfe Imp_NRG  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation) Productivity Tariff lnKL lnso2_ini, a(cic  prov year ownership)

return scalar exp_t2c4=_b[Export]
return scalar abt_t2c4=_b[Abatement_so2]
return scalar tfp_t2c4=_b[Productivity]
return scalar tar_t2c4=_b[Tariff]
return scalar klr_t2c4=_b[lnKL]
return scalar iei_t2c4=_b[lnso2_ini]




 ivreghdfe Imp_abt  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation) Productivity Tariff lnKL lnso2_ini, a(cic  prov year ownership)

return scalar exp_t2c5=_b[Export]
return scalar abt_t2c5=_b[Abatement_so2]
return scalar tfp_t2c5=_b[Productivity]
return scalar tar_t2c5=_b[Tariff]
return scalar klr_t2c5=_b[lnKL]
return scalar iei_t2c5=_b[lnso2_ini]



 ivreghdfe Mix  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation) Productivity Tariff lnKL lnso2_ini, a(cic  prov year ownership)

return scalar exp_t2c6=_b[Export]
return scalar abt_t2c6=_b[Abatement_so2]
return scalar tfp_t2c6=_b[Productivity]
return scalar tar_t2c6=_b[Tariff]
return scalar klr_t2c6=_b[lnKL]
return scalar iei_t2c6=_b[lnso2_ini]



 ivreghdfe Demand  (Export Abatement_so2= tariff_prod ventilation_prod  ventilation) Productivity Tariff lnKL lnso2_ini, a(cic  prov year ownership)

return scalar exp_t2c7=_b[Export]
return scalar abt_t2c7=_b[Abatement_so2]
return scalar tfp_t2c7=_b[Productivity]
return scalar tar_t2c7=_b[Tariff]
return scalar klr_t2c7=_b[lnKL]
return scalar iei_t2c7=_b[lnso2_ini]


********************************************************************************************************


end

capture drop indc
egen indc=group(firm )
drop if indc==.

*-------------------------------------------------------------------------------------------------------------------------
* The following codes generate columns 1-7 of Table A23
*------------------------------------------------------------------------------------------------------------------------------


bootstrap   exp_t2c1=r(exp_t2c1) abt_t2c1=r(abt_t2c1) tfp_t2c1=r(tfp_t2c1) tar_t2c1=r(tar_t2c1)  klr_t2c1=r(klr_t2c1) iei_t2c1=r(iei_t2c1) ///
exp_t2c2=r(exp_t2c2) abt_t2c2=r(abt_t2c2) tfp_t2c2=r(tfp_t2c2) tar_t2c2=r(tar_t2c2)  klr_t2c2=r(klr_t2c2) iei_t2c2=r(iei_t2c2) ///
exp_t2c3=r(exp_t2c3) abt_t2c3=r(abt_t2c3) tfp_t2c3=r(tfp_t2c3) tar_t2c3=r(tar_t2c3)  klr_t2c3=r(klr_t2c3) iei_t2c3=r(iei_t2c3) ///
exp_t2c4=r(exp_t2c4) abt_t2c4=r(abt_t2c4) tfp_t2c4=r(tfp_t2c4) tar_t2c4=r(tar_t2c4)  klr_t2c4=r(klr_t2c4) iei_t2c4=r(iei_t2c4) ///
exp_t2c5=r(exp_t2c5) abt_t2c5=r(abt_t2c5) tfp_t2c5=r(tfp_t2c5) tar_t2c5=r(tar_t2c5)  klr_t2c5=r(klr_t2c5) iei_t2c5=r(iei_t2c5) ///
exp_t2c6=r(exp_t2c6) abt_t2c6=r(abt_t2c6) tfp_t2c6=r(tfp_t2c6) tar_t2c6=r(tar_t2c6)  klr_t2c6=r(klr_t2c6) iei_t2c6=r(iei_t2c6) ///
exp_t2c47=r(exp_t2c7) abt_t2c7=r(abt_t2c7) tfp_t2c7=r(tfp_t2c7) tar_t2c7=r(tar_t2c7)  klr_t2c7=r(klr_t2c7) iei_t2c7=r(iei_t2c7), ///
 rep(30)  seed(5) nodrop : prodboot

 
 